﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PeiYue.Common.HttpContextUser;
using PeiYue.IServices.Sys;
using PeiYue.Model;
using PeiYue.Model.Dto;
using PeiYue.Model.Dto.Sys;

namespace PeiYue.Api.Controllers.Sys
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SysController : ControllerBase
    {
        readonly IMapper _mapper;
        readonly IDicHeaderService _dicHeaderServices;
        IUser _user;
        public SysController(IDicHeaderService dicHeaderServices, IUser user, IMapper mapper)
        {
            _dicHeaderServices = dicHeaderServices;
            _user = user;
            this._mapper = mapper;

        }
        /// <summary>
        /// 查询字典分页列表
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<MessageModel<List<SelectItemDto>>> GetDicIteam([FromQuery] SearchDicHeaderDto querymodel)
        {
            var data = (await _dicHeaderServices.GetDicHeader(querymodel.codec)).ToSelectList();

            var res = new MessageModel<List<SelectItemDto>>() { msg = "获取成功", success = true };
            if (data.Count > 0)
                res.response = data;
            return res;
        }

    }
}
